package finance

class SubtractService {
    
    static transactional = true
    
    def minPrev(array) {
        def subtracted = []
        
        for(int i in 1..<array.size() ) {
            subtracted << array[i] - array[i - 1]
        }
        
        return subtracted
    }
    
    def relPrev(array) {
        def subtracted = []
        
        for(int i in 1..<array.size() ) {
            subtracted << (array[i] - array[i - 1]) / array[i - 1]
        }
        
        return subtracted
    }
    
    def min(left, right) {
        def subtracted = []
        
        for(int i in 0..<array.size() ) {
            subtracted << array[i] - array[i - 1]
        }
        
        return subtracted
    }
}
